﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Media.Imaging;
using System.IO;

namespace HeadLinx.AD.Explorer
{
    static class BitmapUtility
    {
        public static BitmapImage FromFile(string imagePath)
        {
            var bitmap = new BitmapImage();
            bitmap.BeginInit();
            bitmap.UriSource = new Uri(imagePath);
            bitmap.EndInit();
            return bitmap;
        }

        public static BitmapImage FromByteArray(byte[] imageData)
        {
            using (var stream = new MemoryStream(imageData))
            {
                var bitmap = new BitmapImage();
                bitmap.BeginInit();
                bitmap.StreamSource = stream;
                bitmap.EndInit();
                return bitmap;
            }
        }
    }
}
